<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <ul v-if="status === 'ok'">
            <!-- 绑定key 防止修改执行数据, 重新遍历计算渲染所有dom, 有id绑id, 没id绑index -->
            <li v-for="(item, index) in data.users" :key="item.id">
                <h3>{{ item.id }} -- {{ item.name }} -- {{ item.age }}</h3>
            </li>
        </ul>
        <!-- v-for 还可以遍历对象 -->
        <div v-for="(value, key) in data.person">
            {{key}} ---- {{value}}
        </div>
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    status: 'ok',
                    data: {
                        users:[{id:1, name:'张三', age:18},
                                {id:2, name:'李四', age:18},
                                {id:3, name:'王五', age:18},
                            ],
                        person:{
                            name: "张三",
                            age: 18,
                            sex: '男',
                        }
                    },
                }
            },
            methods: {
                
            },
        });
    </script>
</body>
</html>